///*
// * DataSetJDBMBTree.java
// *
// * Created on October 3, 2007, 8:11 AM
// *
// */
//package OLDSTUFF;
//
//import DataSetPackage.*;
//import java.io.File;
//import java.io.IOException;
//import java.util.Iterator;
//import java.util.NoSuchElementException;
//import java.util.Properties;
//import jdbm.RecordManager;
//import jdbm.RecordManagerFactory;
//import jdbm.RecordManagerOptions;
//import jdbm.btree.BTree;
//import jdbm.helper.LongComparator;
//import jdbm.helper.Tuple;
//import jdbm.helper.TupleBrowser;
//
///**
// * Structure to contain featurized data based on a JDBM BTree
// * @author Martin Haulrich
// */
//public class DataSetJDBMBTree { //implements DataSetSimple {
////
////    RecordManager recman;
////
////    BTree data;
////
////    /**
////     * Name of temporary JDBM-file used.
////     */
////    final String JDBMfilename;
////
////    /**
////     * Counter to keep track of next ID-number
////     */
////    Integer nextID;
////
////    /**
////     * Constructor.
////     */
////    public DataSetJDBMBTree() throws DataSetException {
////
////        String name;
////
////        try {
////
////            File hfile = File.createTempFile("DataSet", "");
////            name = hfile.getName();
////            JDBMfilename = name;
////            hfile.delete();
////        } catch (IOException ex) {
////            throw new DataSetException("Could not create new file " + ex.getMessage());
////        }
////
////
////        try {
////
////            Properties props = new Properties();
////            props.setProperty(RecordManagerOptions.DISABLE_TRANSACTIONS, "true");
////            recman = RecordManagerFactory.createRecordManager(name, props);
////            data = BTree.createInstance(recman, new LongComparator());
////            //data = BTree.createInstance(recman, new LongComparator(), new LongSerializer(),new DefaultSerializer(),64);
////            recman.setNamedObject("data", data.getRecid());
////
////            recman.commit();
////            nextID = 1;
////        } catch (IllegalArgumentException ex) {
////            ex.printStackTrace();
////        } catch (IOException ex) {
////            throw new DataSetException("JDBM IOException" + ex.getMessage());
////        }
////    }
////
////    @Override
////    public int size() {
////
////        return data.size();
////    }
////
////    @Override
////    public Integer add(String[] features) throws DataSetException {
////        try {
////
////            Integer dataID = nextID;
////            nextID++;
////            data.insert(dataID, features, true);
////            recman.commit();
////            return dataID;
////        } catch (IOException ex) {
////            throw new DataSetException("JDBM IOException" + ex.getMessage());
////        }
////    }
////
////    @Override
////    public void remove(Integer dataID) throws DataSetException {
////        try {
////            data.remove(dataID);
////            recman.commit();
////        } catch (IOException ex) {
////            throw new DataSetException("JDBM IOException" + ex.getMessage());
////        }
////
////    }
////
////    @Override
////    public DataIDs getDataIDs() throws DataSetException {
////
////        /// ************
////        /// Change this. If 1 dataids exists the array will take up 8Mceret
////
////        int[] idsArray = new int[size()];
////        int i = 0;
////        for (Iterator<Integer> it = keyIterator(); it.hasNext();) {
////            idsArray[i] = it.next();
////            i++;
////        }
////        DataIDs ids = new DataIDs(idsArray);
////
////
////        return ids;
////    }
////
////    @Override
////    public String[] getFeatures(Integer dataID) throws DataSetException {
////        try {
////
////            return (String[]) data.find(dataID);
////        } catch (IOException ex) {
////            throw new DataSetException("JDBM IOException" + ex.getMessage());
////        }
////    }
////
////    @Override
////    public Iterator<Integer> keyIterator() throws DataSetException {
////        return new DataSetKeyIterator();
////    }
////
////    @Override
////    public Iterator featuresIterator() throws DataSetException {
////        return new DataSetFeaturesIterator();
////    }
////
////    /**
////     * Class for the keyIterator
////     */
////    class DataSetKeyIterator implements Iterator<Integer> {
////
////        TupleBrowser iterator;
////
////        Integer nextElement;
////
////        /**
////         * Constructor
////         */
////        public DataSetKeyIterator() throws DataSetException {
////            try {
////
////                iterator = data.browse();
////                nextElement = null;
////            } catch (IOException ex) {
////                throw new DataSetException("JDBM IOException" + ex.getMessage());
////            }
////        }
////
////        @Override
////        public void remove() {
////            throw new UnsupportedOperationException("This Operation is not supported by this iterator");
////        }
////
////        @Override
////        public Integer next() {
////            if (nextElement == null) {
////                Tuple telem = new Tuple();
////                try {
////                    iterator.getNext(telem);
////                } catch (IOException ex) {
////                    throw new NoSuchElementException("JDBM Exception: " + ex.getMessage());
////                }
////                Integer elem = (Integer) telem.getKey();
////                if (elem == null) {
////                    throw new NoSuchElementException();
////                } else {
////                    return elem;
////                }
////
////            } else {
////                Integer elem = nextElement;
////                nextElement = null;
////                return elem;
////            }
////        }
////
////        @Override
////        public boolean hasNext() {
////            if (nextElement == null) {
////                Tuple telem = new Tuple();
////                try {
////                    iterator.getNext(telem);
////                } catch (IOException ex) {
////                    throw new NoSuchElementException("JDBM Exception: " + ex.getMessage());
////                }
////                Integer elem = (Integer) telem.getKey();
////                if (elem == null) {
////                    return false;
////                } else {
////                    nextElement = elem;
////                    return true;
////                }
////
////            } else {
////                return true;
////            }
////
////        }
////    }
////
////    class DataSetFeaturesIterator implements Iterator {
////
////        TupleBrowser iterator;
////
////        String[] nextElement;
////
////        /**
////         * Constructor
////         */
////        public DataSetFeaturesIterator() throws DataSetException {
////            try {
////                iterator = data.browse();
////                nextElement = null;
////            } catch (IOException ex) {
////                throw new DataSetException("JDBM IOException" + ex.getMessage());
////            }
////        }
////
////        @Override
////        public void remove() {
////            throw new UnsupportedOperationException("This Operation is not supported by this iterator");
////        }
////
////        @Override
////        public String[] next() {
////            if (nextElement == null) {
////                Tuple telem = new Tuple();
////                try {
////
////                    iterator.getNext(telem);
////                } catch (IOException ex) {
////                    throw new NoSuchElementException("JDBM Exception: " + ex.getMessage());
////                }
////
////                String[] elem = (String[]) telem.getValue();
////                if (elem == null) {
////                    throw new NoSuchElementException();
////                } else {
////                    return elem;
////                }
////
////            } else {
////                String[] elem = nextElement;
////                nextElement = null;
////                return elem;
////            }
////        }
////
////        @Override
////        public boolean hasNext() {
////            if (nextElement == null) {
////                Tuple telem = new Tuple();
////                try {
////
////                    iterator.getNext(telem);
////                } catch (IOException ex) {
////                    throw new NoSuchElementException("JDBM Exception: " + ex.getMessage());
////                }
////
////                String[] elem = (String[]) telem.getValue();
////
////                if (elem == null) {
////                    return false;
////                } else {
////                    nextElement = elem;
////                    return true;
////                }
////
////            } else {
////                return true;
////            }
////
////        }
////    }
//}